class Db {
  static getInstance () { //单例
    if (!Db.instance) {
      Db.instance = new Db()
    }
    return Db.instance
  }
  constructor () {
    console.log('实例化会触发构造函数')
    this.connect()
  }
  connect () {
    console.log('连接数据库')
  }
  find () {
    console.log('查询数据库')
  }
}

let myDb = Db.getInstance()
let myDb2 = Db.getInstance()
let myDb3 = Db.getInstance()
let myDb4 = Db.getInstance()
let myDb5 = Db.getInstance()


myDb5.find()
myDb4.find()